For user-wide: ~/.profile or ~/.bashrc
For system-wide: /etc/profile
source ~/.bashrc
or source /etc/profile
can make the newly added (not the removed) environment variables for the current cmd window available immediately. However, you need to re-login to make them user-wide or system-wide.
Note that after you sudo su
(not using sudo privilege), the environment variables will be lost. You need to re-login. Because sudo su
will erase newly exported variables.
For permanent system-wide change even after sudo su
, you should modify /etc/environment, which is not recommended. Because /etc/environment cannot recognize intermediate variable such as $JAVA_HOME. Sometimes misusing /etc/environment may result in your failure in login.
Not recommend running sudo su
and then modifying ~/.profile or ~/.bashrc.